package com.test.lotterysystem.Comment.Utils;

import com.test.lotterysystem.Comment.ErrorCode.ControllerErrorCode;
import com.test.lotterysystem.Comment.Exception.ControllerException;
import com.test.lotterysystem.Controller.Result.UserLoginResult;
import com.test.lotterysystem.Controller.Result.UserRegisterResult;
import com.test.lotterysystem.Service.DTO.UserLoginDTO;
import com.test.lotterysystem.Service.DTO.UserRegisterDTO;
import org.springframework.beans.BeanUtils;

public class MyBeanUtil {
    public static UserRegisterResult transOfUserRegisterResult(UserRegisterDTO userRegisterDTO){
        if(userRegisterDTO==null){
            throw new ControllerException(ControllerErrorCode.TRANS_ERROR);
        }
        UserRegisterResult userRegisterResult = new UserRegisterResult();
        BeanUtils.copyProperties(userRegisterDTO,userRegisterResult);
        return userRegisterResult;
    }

    public static UserLoginResult transOfUserLoginResult(UserLoginDTO userLoginDTO){
        if(userLoginDTO==null){
            throw new ControllerException(ControllerErrorCode.TRANS_ERROR);
        }
        UserLoginResult userLoginResult = new UserLoginResult();
        BeanUtils.copyProperties(userLoginDTO,userLoginResult);
        return userLoginResult;
    }
}
